export enum UserVmRole {
  Admin = 'Admin',
  User = 'User',
}

export interface IUserVm {
  createdAt?: Date | null;
  updatedAt?: Date | null;
  id?: string | null;
  username: string;
  firstName?: string | null;
  lastName?: string | null;
  fullName?: string | null;
  role?: UserVmRole | null;
}

export class UserVm implements IUserVm {

  constructor(data?: IUserVm) {
      if (data) {
          for (const property in data) {
              if (data.hasOwnProperty(property)) {
                  (<any>this)[property] = (<any>data)[property];
              }
          }
      }
  }
  createdAt?: Date | null;
  updatedAt?: Date | null;
  id?: string | null;
  username!: string;
  firstName?: string | null;
  lastName?: string | null;
  fullName?: string | null;
  role?: UserVmRole | null;

  static fromJS(data: any): UserVm {
      data = typeof data === 'object' ? data : {};
      const result = new UserVm();
      result.init(data);
      return result;
  }

  init(data?: any) {
      if (data) {
          this.createdAt = data['createdAt'] ? new Date(data['createdAt'].toString()) : <any>null;
          this.updatedAt = data['updatedAt'] ? new Date(data['updatedAt'].toString()) : <any>null;
          this.id = data['id'] !== undefined ? data['id'] : <any>null;
          this.username = data['username'] !== undefined ? data['username'] : <any>null;
          this.firstName = data['firstName'] !== undefined ? data['firstName'] : <any>null;
          this.lastName = data['lastName'] !== undefined ? data['lastName'] : <any>null;
          this.fullName = data['fullName'] !== undefined ? data['fullName'] : <any>null;
          this.role = data['role'] !== undefined ? data['role'] : <any>null;
      }
  }

  toJSON(data?: any) {
      data = typeof data === 'object' ? data : {};
      data['createdAt'] = this.createdAt ? this.createdAt.toISOString() : <any>null;
      data['updatedAt'] = this.updatedAt ? this.updatedAt.toISOString() : <any>null;
      data['id'] = this.id !== undefined ? this.id : <any>null;
      data['username'] = this.username !== undefined ? this.username : <any>null;
      data['firstName'] = this.firstName !== undefined ? this.firstName : <any>null;
      data['lastName'] = this.lastName !== undefined ? this.lastName : <any>null;
      data['fullName'] = this.fullName !== undefined ? this.fullName : <any>null;
      data['role'] = this.role !== undefined ? this.role : <any>null;
      return data;
  }
}
